#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int mod=998244353;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

	int t;
	cin >> t;
	while(t--)
	{
		string s;
		cin >> s;
		int a=0,b=0,c=0,d=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]>=65&&s[i]<=90)
			{
				a++;
			}
			else if(s[i]>=97&&s[i]<=122)
			{
				b++;
			}
			else if(s[i]>=48&&s[i]<=57)
			{
				c++;
			}
			else
			{
				d++;
			}
		}
		if(s.size()>=8&&s.size()<=16&&((a!=0&&b!=0&&c!=0)||(a!=0&&b!=0&&d!=0)||(d!=0&&b!=0&&c!=0)||(a!=0&&b!=0&&c!=0&&d!=0)))
		cout << "YES" << endl;
		else
		{
			cout << "NO" << endl;
		}
	}
    return 0;
}

